<?php
/**
 * 
 * ClientEngage: ClientEngage Visitor Voice (http://www.clientengage.com)
 * Copyright 2012, ClientEngage (http://www.clientengage.com)
 *
 * You must have purchased a valid license from CodeCanyon in order to have 
 * the permission to use this file.
 * 
 * You may only use this file according to the respective licensing terms 
 * you agreed to when purchasing this item on CodeCanyon.
 * 
 * 
 * 
 *
 * @author          ClientEngage <contact@clientengage.com>
 * @copyright       Copyright 2013, ClientEngage (http://www.clientengage.com)
 * @link            http://www.clientengage.com ClientEngage
 * @since           ClientEngage - Visitor Voice v 1.0
 * 
 */
?>
<?php
if ($visitorform['Visitorform']['active'] === false)
{
    echo '<!-- ' . __('Visitorform Inactive') . '-->';
    return;
}
?>
<script type="text/javascript">
    var isSuccessPage = false;
    var isFormPage = true;

    $.validator.setDefaults({ignore: ''});
    $.validator.setDefaults({
        errorPlacement: function(error, element) {
            $(element).parents('.control-group').addClass('error');
            $(element).parents('.control-group').find('.error-message').remove();
            $(element).parents('.control-group').append('<div class="error-message">' + $(element).parents('.control-group').find('[data-error-message]').attr('data-error-message') + '</div>');
        },
        success: function(error, element) {
            $(element).parents('.control-group').removeClass('error');
            $(element).parents('.control-group').find('.error-message').remove();
        }
    });
    $(function() {
        $(".visitorform_form").validate({
            ignore: '.input-container.radio :hidden, .input-container.checkbox :hidden, .checkbox_multiple :hidden'
        });
        $(".checkbox_multiple.required input[type=checkbox]").each(function() {
            $(this).rules("add", "required");
        });
    });
<?php echo $visitorform['Formtheme']['js']; ?>
</script>
<style type="text/css">
<?php echo $this->Html->minifyCss($visitorform['Formtheme']['css']); ?>  
</style>
<div class="info-container">
    <h1><?php echo $visitorform['Visitorform']['title']; ?></h1>
    <div class="form-description"><?php echo $visitorform['Visitorform']['description']; ?></div>
</div>
<?php
echo $this->Session->flash();
echo $this->Customform->create(null, array('class' => 'visitorform_form', 'novalidate'));
$started = $this->Form->value('Visitorvoice.started') ? $this->Form->value('Visitorvoice.started') : date('Y-m-d H:i:s');
echo $this->Customform->input('Visitorvoice.started', array('type' => 'hidden', 'value' => $started));
echo $this->Customform->input('Visitorvoice.referer', array('type' => 'hidden', 'value' => ($this->Form->value('Visitorvoice.referer') !== null ? $this->Form->value('Visitorvoice.referer') : $referer)));

foreach ($visitorform['Field'] as $field)
{
    echo $this->Customform->renderField($field);
}
echo $this->Customform->end();
